<template>
	<view class="container">
		<view class="user-info">
			<view class="user">
				<img :src="userInfo!=''? userInfo.avatar : '@/static/logo.png'" alt="" />
				<view>
					<text>{{identity == '' ? '普通用户' : identity.name}}</text>
					<text>{{userInfo != ''? userInfo.phone:'1888888888'}}</text>
				</view>
			</view>
			<view @click="modifyInfo">
				<uni-icons size="40" color="#fff" @click="toUserDetail" type="gear-filled"></uni-icons>
			</view>
		</view>

		<!-- 优惠卷 -->
		<view class="discount">
			<text>优惠券</text>
			<text>100张</text>
		</view>

		<!-- 订单部分 -->
		<view class="order">
			<view>
				<view>我的订单</view>
				<navigator url="/pages/my/myOrder/myOrder?current=0">
					<view>全部订单</view>
					<view class="arrow"></view>
				</navigator>
			</view>
			<view class="order-status">
				<navigator url="/pages/my/myOrder/myOrder?current=1">
					<img src="@/static/image/order_pay.png" alt="" />
					<view>
						待支付
					</view>
				</navigator>
				<navigator url="/pages/my/myOrder/myOrder?current=2">
					<img src="@/static/image/order_loading.png" alt="" />
					<view>
						待使用
					</view>
				</navigator>
				<navigator url="/pages/my/myOrder/myOrder?current=3">
					<img src="@/static/image/order_success.png" alt="" />
					<view>
						待评价
					</view>
				</navigator>
			</view>
		</view>
		<view class="service">
			<view>
				我的服务
			</view>
			<uni-grid :column="4" :show-border="false" :highlight="true">
				<uni-grid-item>
					<navigator url="/pages/CouponsCentre/CouponsCentre">
						<img src="@/static/maintain.png" alt="" />
						<view>领券中心</view>
					</navigator>
				</uni-grid-item>
				<uni-grid-item>
					<view>
						<img src="@/static/image/积分商城.png" alt="" />
						<view>积分商城</view>
					</view>
				</uni-grid-item>
				<uni-grid-item>
					<navigator url="/pages/my/myCar/myCar">
						<img src="@/static/car.png" alt="" />
						<view>我的车辆</view>
					</navigator>
				</uni-grid-item>
				<uni-grid-item>
					<navigator url="/pages/my/bill/bill">
						<img src="@/static/pay.png" alt="" />
						<view>消费记录</view>
					</navigator>
				</uni-grid-item>
				<uni-grid-item>
					<navigator url="/pages/my/myMaintain/myMaintain">
						<img src="@/static/fix.png" alt="" />
						<view>我的维修</view>
					</navigator>
				</uni-grid-item>
				<uni-grid-item>
					<navigator url="/pages/my/feedback/feedback">
						<img src="@/static/opinion.png" alt="" />
						<view>意见反馈</view>
					</navigator>
				</uni-grid-item>
				<uni-grid-item>
					<navigator>
						<img src="@/static/image/消息中心.png" alt="" />
						<view>消息中心</view>
					</navigator>
				</uni-grid-item>
				<uni-grid-item>
					<view @click="getIdentity">
						<img src="@/static/image/实名认证.png" alt="" />
						<view>实名认证</view>
					</view>
				</uni-grid-item>
			</uni-grid>
		</view>
		<view class="logout" @click="logout">
			<text>退出登录</text>
		</view>

		<uni-popup ref="share" type="share" safeArea backgroundColor="#fff">
			<uni-popup-share></uni-popup-share>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: '',
				identity: ''
			}
		},
		onLoad() {
			this.userInfo = uni.getStorageSync('userInfo')
			this.identity = uni.getStorageSync('identity')
		},
		methods: {
			// 前往修改用户详情
			toUserDetail() {

			},

			getIdentity() {
				if (this.identity != '') {
					uni.showToast({
						title: '您已通过实名认证',
						icon: 'none',
						duration: 2000
					})
				} else {
					uni.navigateTo({
						url: '/pages/my/identityVerification/identityVerification'
					})
				}
			},
			// 退出客户端
			logout() {
				uni.redirectTo({
					url: '/pages/login/login'
				})
			},
			modifyInfo() {
				uni.navigateTo({
					url: '/pages/my/myInfo/myInfo'
				})
			},
		}
	}
</script>

<style>
	page {
		background-color: #fff;
	}

	.container {
		height: 100vh;
		background: linear-gradient(to bottom, #5290FF 22%, #fff 22%);
	}

	.user-info {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 70rpx 30rpx 40rpx;
	}

	.user {
		display: flex;
		color: #fff;
		align-items: center;
	}

	.user>view {
		margin-left: 20rpx;
	}

	.user>view>text {
		display: block;
	}

	.user>img {
		width: 120rpx;
		height: 120rpx;
		border-radius: 80rpx;
	}

	.discount {
		display: flex;
		justify-content: space-between;
		align-items: center;
		background-color: #fff;
		border-radius: 40rpx;
		box-shadow: 0px 0px 4px 1px rgba(0, 0, 0, 0.2);
		padding: 0 60rpx;
		font-size: 40rpx;
		height: 160rpx;
		margin: 0 80rpx;
	}

	.order {
		background-color: #fff;
		border-radius: 20rpx;
		box-shadow: 0px 0px 4px 1px rgba(0, 0, 0, 0.2);
		padding: 0 40rpx;
		margin: 30rpx 20rpx 30rpx;
	}

	.order>view:nth-child(1) {
		display: flex;
		justify-content: space-between;
		padding: 20rpx 0;
	}

	.order>view:nth-child(1)>view:nth-child(1) {
		font-weight: bold;
	}

	.order>view:nth-child(1)>navigator {
		display: flex;
		align-items: center;
		font-size: 28rpx;
	}

	.order-status {
		display: flex;
		justify-content: space-between;
		text-align: center;
		font-size: 28rpx;
		padding-bottom: 20rpx;
	}

	.order-status img {
		width: 60rpx;
		height: 60rpx;
	}

	.my-service>img {
		width: 80rpx;
		height: 80rpx;
	}

	.service {
		padding: 0 30rpx;
	}

	.service>view:nth-child(1) {
		font-weight: bold;
	}

	.uni-grid-item {
		text-align: center;
		align-items: center;
		font-size: 24rpx;
	}

	.uni-grid-item img {
		width: 50rpx;
		height: 46rpx;
		padding: 10rpx 0;
	}

	.logout {
		padding: 20rpx;
		margin-top: 60rpx;
		text-align: center;
		font-size: 28rpx;
		color: #5290FF;
	}

	.arrow {
		width: 20rpx;
		height: 20rpx;
		border-top: 2rpx solid #aaa;
		border-right: 2rpx solid #aaa;
		transform: rotate(45deg);
	}
</style>